<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>所有商品</title>
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="angularjs/pagination.css">
    <script src="bootstrap/js/jquery.min.js"></script>
    <script src="bootstrap/js/bootstrap.min.js"></script>
    <script src="angularjs/angular.min.js"></script>
    <script src="angularjs/pagination.js"></script>
</head>
<script>
    //创建一个app
    var app = angular.module("myApp", []);
    app.controller("myController", function ($scope, $http) {
        //敲代码处
        $scope.showAll = function () {

            $http.get("/product/showAll").success(function (data) {
                $scope.list = data;
            });
        }
        $scope.addCar = function (p) {
            $http.post("/usercar/addCar",p).success(function (data) {
                $scope.Num = data.pscs;
            });
        }

    })
</script>
<body ng-app="myApp" ng-controller="myController" ng-init="showAll()">
<div class="container">
    <div class="panel panel-primary">
        <div class="panel-heading text-center">
            <h1>欢迎光临华为商城</h1>
        </div>
        <div class="panel-body text-center">
            <div class="col-lg-3" ng-repeat="p in list">
                <table class="table table-condensed table-bordered table-hover table-striped text-center">
                    <tr>
                        <td>
                            <img src="img/{{p.uimg}}" style="width: 210px;height: 210px">
                        </td>
                    </tr>

                    <tr>
                        <td>
                            {{p.uname}}
                        </td>
                    </tr>
                    <tr>
                        <td>
                            ￥{{p.price}}
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <button ng-click="Pay()" class="btn btn-success">立即购买</button>
                            <button ng-click="addCar(p)" class="btn btn-warning">加入购物车</button>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="text-right">
                <button ng-click="addCar" class="btn btn-success btn-lg" style="margin-right: 100px">查看购物车<span
                        class="badge">{{Num}}</span></button>
            </div>
        </div>
        <div class="panel-footer text-right">
            &copy;华为开发团队
        </div>
    </div>
</div>
</body>
</html>